package com.roadjava.tutor.handler.back.admin;

import com.roadjava.tutor.bean.dto.StudentDemandDTO;
import com.roadjava.tutor.bean.dto.UserDTO;
import com.roadjava.tutor.bean.entity.Member;
import com.roadjava.tutor.bean.res.ResultDTO;
import com.roadjava.tutor.bean.res.TableResult;
import com.roadjava.tutor.bean.vo.StudentDemandVO;
import com.roadjava.tutor.service.MemberService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhaodaowen
 * @see <a href="http://www.roadjava.com">乐之者java</a>
 */
@Controller
@RequestMapping("/admin")
public class AdminHandler {
    @Resource
    private MemberService memberService;
    /**
     * 到管理员主页面
     */
    @GetMapping("/toMain")
    public String toManage() {
        return "back/admin/adminMain";
    }
    /**
     * 到注册用户管理页面
     */
    @GetMapping("/toMemberManage")
    public String toMyAppointment() {
        return "back/admin/memberManage";
    }

    /**
     * 加载求职表格
     */
    @PostMapping("/loadMemberTable") @ResponseBody
    public ResultDTO<TableResult<Member>> loadMemberTable(UserDTO dto){
        TableResult<Member> tableResult=new TableResult<>();
        ResultDTO<List<Member>> result = memberService.loadMemberTable(dto);
        tableResult.setTotalCount(result.getTotal());
        tableResult.setRows(result.getData());
        return ResultDTO.buildSuccess(tableResult);
    }
}
